package com.cmj.controller;

import com.cmj.domain.ResponseResult;
import com.cmj.domain.dto.LinkDto;
import com.cmj.domain.entity.Link;
import com.cmj.domain.vo.LinkVo;
import com.cmj.domain.vo.PageVo;
import com.cmj.service.LinkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 这是注释
 */
@RestController
@RequestMapping("/content/link")
public class LinkController {
    @Autowired
    private LinkService linkService;

    /***
     * 获取友链
     * @return 返回友链
     */
    @GetMapping("/list")
    public ResponseResult<PageVo> getAllLink(Integer pageNum, Integer pageSize, LinkDto linkDto){
        return linkService.getAllLink(pageNum,pageSize,linkDto);
    }

    @PostMapping
    public ResponseResult<LinkVo> addLink(@RequestBody Link link){
        return linkService.addLink(link);
    }

    //删除
    @DeleteMapping("{id}")
    public ResponseResult delLink(@PathVariable("id") Long[] id){
        return linkService.delLink(id);
    }

    //获取更新项信息
    @GetMapping("{id}")
    public ResponseResult<LinkVo> getLink(@PathVariable("id") Long id){
        return linkService.getLink(id);
    }

    //快速更改状态
    @PutMapping("/changeLinkStatus")
    public ResponseResult changeLinkStatus(@RequestBody Link link){
        return linkService.updateLink(link);
    }

    //更新信息
    @PutMapping
    public ResponseResult updateLink(@RequestBody Link link){
        return linkService.updateLink(link);
    }
}
